using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Threading;
using System.Windows.Forms;
using ALib;
using TradingPlatform.IB.TradingClient;

namespace TradingPlatform.IB.TradingClient
{
    class Program
    {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main(string[] args)
        {
            //TestOrderManagementDb();

            if (DateTime.Now.DayOfWeek == DayOfWeek.Saturday || DateTime.Now.DayOfWeek == DayOfWeek.Sunday)
            {
                //return;
            }

            Logger.Enabled = true;
            Logger.LogDir = new DirectoryInfo("Log");

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new TradingGui(new TradingKernel_InteractiveBrokers()));
            Logger.Save();
        }

        private static void TestOrderManagementDb()
        {
            OrderManagementDb orderManagementDb = new OrderManagementDb();
            Random r = new Random();

            for (int j = 0; j < 10; j++)
            {
                orderManagementDb.SendOrder("A", j, 10, r.Next(-200, -99));
            }

            for (int j = 0; j < 10; j++)
            {
                orderManagementDb.CancelOrder(j);
                orderManagementDb.FillOrder_TotalRemaining(j, 0);
            }
        }
    }
}